package com.ctgu.service.impl;

import com.ctgu.mapper.HomeworkDetailMapper;
import com.ctgu.service.HomeworkDetailService;
import com.ctgu.vo.HomeworkDetail;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class HomeworkDetailServiceImpl implements HomeworkDetailService {

    @Resource
    private HomeworkDetailMapper homeworkDetailMapper;

    @Override
    public void homeworkSubmit(int homeworkId, int studentId, String homework) {
        HomeworkDetail homeworkDetail = new HomeworkDetail();
        homeworkDetail.setHomeworkId(homeworkId);
        homeworkDetail.setStudentId(studentId);
        homeworkDetail.setTheDetail(homework);
        homeworkDetailMapper.updateByPrimaryKeySelective(homeworkDetail);
    }

    @Override
    public List<HomeworkDetail> StudentHomeworkDetail(int homeworkId) {
        return homeworkDetailMapper.SelectStudentHomeworkDetail(homeworkId);
    }

    @Override
    public HomeworkDetail selectByPrimaryKey(int homeworkId, int studentId) {
        HomeworkDetail homeworkDetail = new HomeworkDetail();
        homeworkDetail.setHomeworkId(homeworkId);
        homeworkDetail.setStudentId(studentId);
        return homeworkDetailMapper.selectByPrimaryKey(homeworkDetail);
    }

    @Override
    public void updateByPrimaryKey(int homeworkId, int studentId,String level) {
        HomeworkDetail homeworkDetail = new HomeworkDetail();
        homeworkDetail.setHomeworkId(homeworkId);
        homeworkDetail.setStudentId(studentId);
        homeworkDetail.setLevel(level);
        homeworkDetailMapper.updateByPrimaryKeySelective(homeworkDetail);
    }
}
